package 暑假实习面试.腾讯面试题;

import java.util.Scanner;

public class No4 {

    private static boolean dg(String str1,String str2) {

        int minLength=str1.length()/2;
        String str1Left=str1.substring(0,minLength);
        String str1Right=str1.substring(minLength);
        String str2Left=str2.substring(0,minLength);
        String str2Right=str2.substring(minLength);

        if(
                (str1Left.equals(str2Left)&&str1Right.equals(str2Right))||
                        (str1Left.equals(str2Right)&&str1Right.equals(str2Left))
        ){
            return true;
        }else{

            if(str1Left.equals(str2Left)&&dg(str1Right,str2Right)){
                return true;
            }

            if(str1Right.equals(str2Right)&&dg(str1Left,str2Left)){
                return true;
            }
            if((str1Left.equals(str2Right)&&dg(str1Right,str2Left))){
                return true;
            }
            if(str1Right.equals(str2Left)&&dg(str1Left,str2Right)){
                return true;
            }

            return false;
        }

    }

    public static void main(String[] args) {

        Scanner input=new Scanner(System.in);

        int count=input.nextInt();

        for (int i = 0; i < count; i++) {
            String str1=input.next();
            String str2=input.next();

            if(str1.length()%2==0){
                //偶数
                if(dg(str1,str2)){
                    System.out.println("YES");
                }else{
                    System.out.println("NO");
                }
            }else{
                //奇数
                if(str1.equals(str2)) {
                    System.out.println("YES");
                }else{
                    System.out.println("NO");
                }
            }

        }

    }

}
